/*
 * @lc app=leetcode.cn id=14 lang=javascript
 *
 * [14] 最长公共前缀
 */

// @lc code=start
/**
 * @param {string[]} strs
 * @return {string}
 */
var longestCommonPrefix = function (strs) {
    if (strs.length == 0) return "";
    let ars = strs[0];
    for (let i = 1; i < strs.length; i++) {
        let j = 0;
        for(;j<strs[i].length;j++) {
            if(ars[j] != strs[i][j]) {
                break;
            }
        }
        ars = ars.substring(0,j);
        if(ars == '') return ars;
    }
    return ars;
};
// @lc code=end